package com.efe.ms.esservice.service;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import javax.annotation.Resource;

import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.stereotype.Service;

import com.efe.ms.esservice.dao.AmazonBrandKeywordRepository;
import com.efe.ms.esservice.model.AmazonBrandKeyword;
@Service
public class AmazonBrandKeywordServiceImpl extends BaseSearchServiceImpl implements AmazonBrandKeywordService {
	@Resource
	private AmazonBrandKeywordRepository amazonBrandKeywordRepository;
	@Resource
	private ElasticsearchRestTemplate elasticsearchRestTemplate;
	@Resource
	private RestHighLevelClient restHighLevelClient;
	
	@Override
	public String searchToJson(String indices, SearchSourceBuilder searchSourceBuilder) throws IOException {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public AmazonBrandKeyword getById(String id) {
		Optional<AmazonBrandKeyword> findById = amazonBrandKeywordRepository.findById(id);
		return findById.get();
	}
	@Override
	public List<AmazonBrandKeyword> getAll(int index, int pageSize) {
		Pageable pageable = PageRequest.of(index,pageSize);
		 List<AmazonBrandKeyword> list = new ArrayList<>();
	     Iterable<AmazonBrandKeyword> findAll = amazonBrandKeywordRepository.findAll(pageable);
	     for (AmazonBrandKeyword productDocument : findAll) {
	    	 list.add(productDocument);
		}
		return list;
	}
	@Override
	public String getNewestDate() {
//		elasticsearchRestTemplate.f
//		return amazonBrandKeywordRepository.searchSimilar(null, new , null);
		return null;
	}

	

}
